﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Script.Serialization;

namespace SocialWebpart
{
    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class JSONForTwitter
    {
        /// <summary>
        /// Creates a JSONObject by parsing a string.
        /// </summary>
        public static List<RootObject> CreateFromString(string s)
        {
            List<RootObject> objJson;
            JavaScriptSerializer objSerializer = new JavaScriptSerializer();
            try
            {
                objJson = objSerializer.Deserialize<List<RootObject>>(s);
            }
            catch (ArgumentException)
            {
                throw new Exception("JSONException", new Exception("Not a valid JSON string."));
            }

            return objJson;
        }
    }

    public class RetweetedStatus
    {
        public string text { get; set; }
    }

    public class RootObject
    {
        public object contributors { get; set; }
        public object coordinates { get; set; }
        public string created_at { get; set; }
        public int favorite_count { get; set; }
        public bool favorited { get; set; }
        public object geo { get; set; }
        public object id { get; set; }
        public string id_str { get; set; }
        public string in_reply_to_screen_name { get; set; }
        public object in_reply_to_status_id { get; set; }
        public object in_reply_to_status_id_str { get; set; }
        public int? in_reply_to_user_id { get; set; }
        public string in_reply_to_user_id_str { get; set; }
        public string lang { get; set; }
        public object place { get; set; }
        public bool possibly_sensitive { get; set; }
        public int retweet_count { get; set; }
        public bool retweeted { get; set; }
        public string source { get; set; }
        public string text { get; set; }
        public bool truncated { get; set; }
        public User user { get; set; }
        public RetweetedStatus retweeted_status { get; set; }
    }

    public class User
    {
        public string profile_image_url { get; set; }
        public string screen_name { get; set; }
    }
}
